package com.one.rope.mvp.web.config;

import org.springframework.core.env.Environment;

/**
 * @author Weijian.Liu
 * @desc 环境配置
 * @date 2020/2/19 15:36
 */
public class BuildConfig {

  private static BuildConfig config = new BuildConfig();

  public static BuildConfig instance() {
    return config;
  }

  public static void initWithEnvid(Environment env) {
    config.setEnvid(env.getProperty("spring.profiles.active"));
  }

  private String envid;

  public String getEnvid() {
    return envid;
  }

  public void setEnvid(String envid) {
    this.envid = envid;
  }

  public static boolean isProduction() {
    return "pro".equalsIgnoreCase(config.getEnvid());
  }

  public static boolean isTest() {
    return "test".equalsIgnoreCase(config.getEnvid());
  }

  public static boolean isDebug() {
    return !isProduction();
  }

}
